package com.xjgc.eip.panel.controller;


import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jeecg.common.api.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjgc.common.entity.ReturnResult;
import com.xjgc.eip.panel.entity.ZxjEipDnbCssz;
import com.xjgc.eip.panel.mapper.ZxjEipDnbCsszMapper;
import com.xjgc.eip.panel.service.ZxjEipDnbCsszService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wxy
 * @since 2019-11-07
 */
@RestController
@RequestMapping("/zxjEipDnbCssz")
public class ZxjEipDnbCsszController {

    @Autowired
    private ZxjEipDnbCsszService zxjEipDnbCsszService;
    @Autowired
    private ZxjEipDnbCsszMapper zxjEipDnbCsszMapper;

    @RequestMapping("paramIntro")
    public ReturnResult paramIntro(Integer amount,@RequestHeader(value = "supplierCode") String supplierCode){
        //设置默认值
        amount=(amount==null)?1:amount;

        Map map=new HashMap();
        map.put("amount",amount);
        map.put("SUPPLIER_CODE",supplierCode);
        List<ZxjEipDnbCssz> list = zxjEipDnbCsszMapper.selectNo(map);
       /* ZxjEipDnbCssz zxjEipDnbCssz=new ZxjEipDnbCssz();
        zxjEipDnbCssz.setIoflag(1);
        QueryWrapper<ZxjEipDnbCssz> queryWrapper = new QueryWrapper<>();
        queryWrapper.setEntity(zxjEipDnbCssz);
        queryWrapper.orderByAsc("\"CHECK_TIME\"");
        Page<ZxjEipDnbCssz> page = new Page<ZxjEipDnbCssz>(1, amount);*/
        ReturnResult returnResult=new ReturnResult();
//        List<ZxjEipDnbCssz> list=zxjEipDnbCsszService.page(page,queryWrapper).getRecords();
        returnResult.setData(list);
        if(null!=list&&list.size()>0){
            for (ZxjEipDnbCssz zed:list) {//设为已读
                zed.setIoflag(0);
                zed.setGrabTime(new Date());
            }
            zxjEipDnbCsszService.updateBatchById(list);
        }
        return returnResult;
    }

    @RequestMapping("list")
    public Result<?> list(@RequestHeader(value = "supplierCode" ,required = false)String supplierCode, ZxjEipDnbCssz zxjEipDnbCssz){
        String testCode = zxjEipDnbCssz.getTestCode();
        supplierCode=supplierCode==null?"1000069096":supplierCode;
        List<ZxjEipDnbCssz> list = zxjEipDnbCsszService.list(supplierCode,testCode);
        Page<ZxjEipDnbCssz> pageList  = new Page<>();
        pageList.setRecords(list);
        return Result.ok(pageList);
    }

}

